package com.yupi.springbootinit.config;

import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * InfluxDB 2.x 客户端配置
 */
@Configuration
public class InfluxV1Config {

    @Value("${influx.url}")
    private String url;

    @Value("${influx.token}")
    private String token;

    @Value("${influx.org}")
    private String org;

    @Value("${influx.bucket}")
    private String bucket;

    @Bean
    public InfluxDBClient influxDBClient() {
        // 使用 token + org + bucket 创建 2.x 客户端
        return InfluxDBClientFactory.create(url, token.toCharArray(), org, bucket);
    }
}